﻿<UserControl x:Class="ProgrammersCalculator.View.RegexView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:conv="clr-namespace:ProgrammersCalculator.Convertor"
             xmlns:System="clr-namespace:System;assembly=mscorlib"
             xmlns:dc="clr-namespace:ProgrammersCalculator.ViewModel"
             xmlns:wpf="clr-namespace:ProgrammersCalculator.Common"
             xmlns:WinForms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="300">
    <UserControl.DataContext>
        <dc:RegexViewModel x:Name="x"></dc:RegexViewModel>
    </UserControl.DataContext>
    <UserControl.Resources>


        <conv:IsMatchConverter x:Key="IsMatchConverter"></conv:IsMatchConverter>
    </UserControl.Resources>
    <DockPanel>
        <Border DockPanel.Dock="Top"
                Style="{DynamicResource styleContentArea}">
            <Grid>
                <Grid.Resources>
                    <Style x:Key="TextFields"
                           TargetType="TextBox">
                        <Setter Property="Margin"
                                Value="0"></Setter>
                    </Style>
                </Grid.Resources>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <!-- HEADER -->
                <Border Grid.Row="0"
                        Style="{DynamicResource styleContentAreaHeader}">
                    <Grid>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock FontSize="20"
                                       Padding="8"
                                       VerticalAlignment="Center">Regex Tester</TextBlock>
                        </StackPanel>
                    </Grid>
                </Border>

                <!--CONTENT AREA-->
                <Grid Grid.Row="1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="100" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="2*" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="2*" />
                    </Grid.RowDefinitions>
                    <TextBox x:Name="txtRegexExpression"
                             Grid.Row="0"
                             TextWrapping="Wrap"
                             VerticalScrollBarVisibility="Auto"
                             FontSize="16"
                             FontFamily="Comic Sans MS"
                             FontWeight="Normal"
                             FontStyle="Normal"
                             FontStretch="Normal"
                             KeyUp="txtRegexExpression_KeyUp">
                        <TextBox.CommandBindings>
                            <CommandBinding Command='Replace'
                                            Executed='ReplaceSelectionWithCommandParameter' />
                        </TextBox.CommandBindings>
                    </TextBox>
                    <GroupBox Header="Regular Expression Options" Padding="10" Margin="10,0,0,10"
                              Grid.Row="1">
                    <StackPanel Orientation="Horizontal">
                            <WrapPanel>
                                <CheckBox Content="Ignore Case"
                                  x:Name="ignoreCaseCheckBox"
                                  IsChecked="True"></CheckBox>
                        <CheckBox Content="Multiline"
                                  x:Name="isMultiline"
                                  IsChecked="True"></CheckBox>
                            <CheckBox Content="Ignore Whitespace"
                                      x:Name="isIgnoreSpace"
                                      IsChecked="False"></CheckBox>
                            <CheckBox Content="ECMA Script"
                                      x:Name="isECMAScript"
                                      IsChecked="False"></CheckBox>
                            </WrapPanel>
                        </StackPanel>
                    </GroupBox>
                    <GridSplitter Grid.Row="2"
                                  HorizontalAlignment="Stretch"
                                  
                                  ResizeBehavior="PreviousAndNext"
                                  Background="#FFBCBCBC"
                                  ResizeDirection="Rows"></GridSplitter>
                    <WindowsFormsHost Grid.Row="3">
                        <WinForms:RichTextBox x:Name="richSourceText"
                                             ></WinForms:RichTextBox>
                    </WindowsFormsHost>
                    <GridSplitter Grid.Row="4"
                                  HorizontalAlignment="Stretch"
                                  ResizeBehavior="PreviousAndNext"
                                  Background="#FFBCBCBC"
                                  ResizeDirection="Rows"></GridSplitter>
                    <TextBox x:Name="txtSplit"
                             Grid.Row="5"
                             Style="{StaticResource ResourceKey=TextFields}"
                             VerticalScrollBarVisibility="Auto"
                             IsReadOnly="True"
                             AcceptsReturn="True"
                             AcceptsTab="True"
                             Margin="0,0,0,-101"></TextBox>
                </Grid>
            </Grid>
        </Border>
    </DockPanel>
</UserControl>
